package com.candy.control;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.LinkedList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.candy.service.UserInfoService;

@WebServlet("/getUserInfoes")
public class GetUserInfoServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		UserInfoService service=new UserInfoService();
//		解决中文乱码问题
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		//		接收前端传递进来的参数
		String username=req.getParameter("username");
//		调用业务逻辑处理层获取数据
		LinkedList<LinkedHashMap<String, Object>> userinfoes=service.getUserInfoes(username);
//		将数据放在session中传递给前端
		req.getSession().setAttribute("userinfoes", userinfoes);
//		转发到客户端
		req.getRequestDispatcher("userinfo.jsp").forward(req, resp);
	}
	

}
